﻿using FastShell.Common.Model;
using npcook.Terminal.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace FastShell.Common.Control
{
    public class TabContent
    {
        public TerminalControl terminal { get; set; }
        public Grid grid { get; set; }
        public TreeView treeView = new TreeView();
        public DockPanel filePane = new DockPanel() { LastChildFill = false };
        public TextBox textBox { get; set; }
        public DockPanel operPane = new DockPanel() { HorizontalAlignment = HorizontalAlignment.Right };
        public Button openBtn { get; set; }
        public Button refreshBtn { get; set; }
        public Button uploadBtn { get; set; }
        public Button transferBtn { get; set; }
        public ListView listView = new ListView();
        public ObservableCollection<FileTreeModel> dictList = new ObservableCollection<FileTreeModel>();
        public ObservableCollection<FileTreeModel> fileList = new ObservableCollection<FileTreeModel>();

        public TabContent()
        {
            terminal = new TerminalControl();
            terminal.FontSize = 13;
            terminal.FontFamily = new FontFamily("Consolas");
            terminal.Background = Brushes.Black;
            terminal.Focus();


            //
            grid = new Grid();
            grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(500) });
            grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(25) });
            grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(185) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(200) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(400) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(375) });

            Grid.SetRow(terminal, 0);

            Grid.SetColumnSpan(terminal, 3);
            grid.Children.Add(terminal);

            treeView = new TreeView();
            

            Grid.SetRow(treeView, 1);
            Grid.SetRowSpan(treeView, 2);
            Grid.SetColumn(treeView, 0);
            grid.Children.Add(treeView);

            filePane = new DockPanel() { LastChildFill = false };
            textBox = new TextBox() { Width = 300, Height = 20, Text = "/", BorderBrush = Brushes.Transparent, HorizontalAlignment = HorizontalAlignment.Left };
            filePane.Children.Add(textBox);

            openBtn = new Button() { Width = 20, Height = 20, BorderBrush = Brushes.Transparent, Background = Brushes.Transparent, Content = new Image() { Source = new BitmapImage(new Uri("/Assets/open.png", UriKind.Relative)) } };
            filePane.Children.Add(openBtn);

            refreshBtn = new Button() { Width = 20, Height = 20, BorderBrush = Brushes.Transparent, Background = Brushes.Transparent, Content = new Image() { Source = new BitmapImage(new Uri("/Assets/refresh.png", UriKind.Relative)) } };
            filePane.Children.Add(refreshBtn);

            uploadBtn = new Button() { Width = 20, Height = 20, BorderBrush = Brushes.Transparent, Background = Brushes.Transparent, Content = new Image() { Source = new BitmapImage(new Uri("/Assets/upload.png", UriKind.Relative)) } };
            filePane.Children.Add(uploadBtn);
            Grid.SetRow(filePane, 1);
            Grid.SetColumn(filePane, 1);
            grid.Children.Add(filePane);

            operPane = new DockPanel() { HorizontalAlignment = HorizontalAlignment.Right };
            transferBtn = new Button() { Name = "transferBtn", Width = 20, Height = 20, BorderBrush = Brushes.Transparent, Background = Brushes.Transparent, Content = new Image() { Source = new BitmapImage(new Uri("/Assets/transfer.png", UriKind.Relative)) }, };
            

            operPane.Children.Add(transferBtn);


            operPane.Children.Add(new Button() { Width = 20, Height = 20, BorderBrush = Brushes.Transparent, Background = Brushes.Transparent, Content = new Image() { Source = new BitmapImage(new Uri("/Assets/setting.png", UriKind.Relative)) } });

            Grid.SetRow(operPane, 1);
            Grid.SetColumn(operPane, 2);
            grid.Children.Add(operPane);

            listView = new ListView();
            //listView.Template = tabControl.FindResource("ListView") as ControlTemplate;
            Grid.SetRow(listView, 2);
            Grid.SetColumn(listView, 1);
            Grid.SetColumnSpan(listView, 2);
            grid.Children.Add(listView);
        }
    }
}
